@isTest
private class ArticleControllerTest
{

    private static String testArticleId;
    
    private static void createTestData()
    {
        List<Article__c>articles = new List<Article__c>();
        Article__c article;
        for(Integer i=0;i<10;i++)
        {
            article = new Article__c();
            article.story__c  = 'This is a story' + i;
            article.summary__c  = 'This is a summary' + i;
            article.status__c = 'published';
            articles.add(article);
        }
        insert articles;
        testArticleId = articles.get(0).id;
    }
    
    static testMethod void testArticleController()
    {
        createTestData();
        PageReference pageRef = Page.article;
        pageRef.getParameters().put('articleId', testArticleId);
        Test.setCurrentPage(pageRef);
        ArticleController controller = new ArticleController();
        System.assert(controller.article != null);
    }

    static testMethod void testGetAllArticles()
    {
       createTestData();
       ArticleController controller = new ArticleController();
       System.assert(controller.getAllArticles().size() > 0);
    }
    
    static testMethod void testGetTop3Articles()
    {
       createTestData();
       ArticleController controller = new ArticleController();
       System.assert(controller.getTop3Articles().size() > 0);
    }
    
    static testMethod void testSetController()
    {
       createTestData();
       ArticleController controller = new ArticleController();
       System.assert(controller.setController != null);
       System.assert(controller.hasNext);
       controller.next();
       System.assert(controller.hasPrevious);
       controller.previous();
       System.assert(!controller.hasPrevious);
       controller.last();
       controller.first();
       System.assert(controller.pageNumber == 1);       
       controller.cancel();
       
    }
    

}